import ArithmeticFunctions --http://www.polyomino.f2s.com/david/haskell/codeindex.html

-- computes the nth triangle number
next :: Integer -> Integer
next n = toInteger $ ((2*n + 1)^2 - 1) `div` 8

firstOne :: Integer -> Integer
firstOne x
    | (numDivisors $ triangle) > 500 = triangle
    | otherwise = firstOne (x+1)
      where triangle = next x

main = print $ firstOne 1

